home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NBC Slam Jams!
/
NBC Slam Jams!.iso
/
xtras
/
media_la
/
effector.cst
/
00046_Script_slider
< prev
next >
Wrap
Text File
|
1997-09-30
|
5KB
|
157 lines
-- Slider
property button, bar, direction, min, max, percentage, range, offset, Location,Name,downMem
property msgMovie,msgSprite,msgSpriteNum,sliderMsg,defaultVal
-- a simple horizontal or vertical slider.
-- properties:
-- button; the sprite number of the slider 'button' (the thing that slides)
-- bar; the sprite number of the slider bar itself.
-- direction; #Horizaontal or #Vertical
-- min; the pixel value of the left (or bottom) end of the slider
-- max; the pixel value of the right (or top) end of the slider
-- percentage; the current percentage value represented by the slider
-- range; the number of pixels between 'min' and 'max'
-- offset; the actual pixel location along the slider
-- location; the fixed location of the slider. This does not change, unless the actual
-- location of the slider changes.
-- the developer needs to provide a handler called "sliderIsMoving" which is called whenever the slider's value is changed.
on getPropertyDescriptionList
set s=the currentSpriteNum
if s>0 then
set nameDef=(the name of member (the member of sprite s))
set memDef= nameDef & "*"
set barDef=s-1
end if
set pList=[:]
addProp pList, #Name,[#comment: "Slider Name:", ¼
#format: #string, ¼
#default: nameDef ]
addProp pList, #DownMem,[#comment: "Hilite Image:", ¼
#format: #graphic, ¼
#default: memDef ]
addProp pList,#bar,[#comment: "Range channel:",¼
#format: #integer,¼
#default: barDef]
addProp pList,#direction,[#comment:"Direction:",¼
#format: #symbol,¼
#default:#Horizontal,¼
#range:[#Horizontal,#Vertical]]
addProp pList,#defaultVal,[#comment:"Default Value (%):",¼
#format: #integer,¼
#default:1]
addProp pList,#msgMovie,[#comment:"Message Movie:",¼
#format: #boolean,¼
#default:1]
addProp pList,#msgSprite,[#comment:"Message Sprite:",¼
#format: #boolean,¼
#default:0]
addProp pList,#msgSpriteNum,[#comment:"Sprite Number:",¼
#format: #integer,#default:1]
addProp pList,#sliderMsg,[#comment:"Send this message:",¼
#format: #string,¼
#default:"sliderIsMoving"]
return pList
end
on getBehaviorDescription
return "Creates a slider"
end
on beginSprite me
set sliderMsg=value("#" & sliderMsg)
set button=the spriteNum of me
setDirection(me)
set offset = 0
if defaultVal<1 then set defaultVal=1
if defaultVal>100 then set defaultVal=100
setSlider me, defaultVal
return me
end
on setBar me, b
set bar = b
setDirection(me)
end
on setLocation me,l
case direction of
#Horizontal: set the locV of sprite button = l
#Vertical: set the locH of sprite button = l
end case
setSlider me,percentage
end
on mouseDown me
operate(me)
end
on operate me
set the member of sprite button = member downMem
repeat while the mouseDown
if direction=#horizontal then
set mh = the mouseH
if mh < min then set mh=min
if mh > max then set mh=max
set the locH of sprite button = mh
set offset = mh - min
else -- vertical
set mv= the mouseV
if mv > min then set mv=min
if mv<max then set mv=max
set the locV of sprite button = mv
set offset = min-mv
end if
set percentage = (offset*100) / range
if msgMovie then sliderIsMoving(me)
if msgSprite then sendSprite(msgSpriteNum,sliderMsg,Name,percentage)
sendSprite(button,#step)
updateStage
end repeat
end
on setSlider me,p,flag
set percentage = p
set offset = (range*percentage) / 100
case direction of
#Horizontal: set the locH of sprite button = offset+min
#Vertical: set the locV of sprite button = min-offset
end case
if voidP(flag) then
if msgMovie then sliderIsMoving(me)
if msgSprite then sendSprite(msgSpriteNum,sliderMsg,Name,percentage)
end if
updateStage
end
on setDirection me,d
if not voidP(d) then set direction=d
case direction of
#horizontal:
set min = the left of sprite bar
set max = the right of sprite bar
set range = max - min
--set location = the locV of sprite button
#vertical:
set min = the bottom of sprite bar
set max = the top of sprite bar
set range = min - max -- it's backwards because of the screen coordinates
--set location = the locH of sprite button
end case
end